#include "KSudokuGame.h"

using namespace KSudoku;

KSudokuGame::KSudokuGame(void)
{
	m_pkMapGrid = NULL;
	m_pkUserGrid = NULL;
	m_pkDataProvider = NULL;
	m_pkUI = NULL;
	m_pkOperationManager = NULL;
	m_pkController = NULL;
}

KSudokuGame::~KSudokuGame(void)
{
	delete m_pkMapGrid;
	m_pkMapGrid = NULL;
	delete m_pkUserGrid;
	m_pkUserGrid = NULL;
	delete m_pkDataProvider;
	m_pkDataProvider = NULL;
	delete m_pkUI;
	m_pkUI = NULL;
	delete m_pkController;
	m_pkController = NULL;
}

bool KSudokuGame::Init(void)
{
	bool bEC = false;
	m_pkMapGrid = new KDataGrid;
	m_pkUserGrid = new KDataGrid;
	m_pkDataProvider = new KDummyDataProvider;
	m_pkUI = new KConsoleUI ;
	m_pkOperationManager = new KOperationManager;
	m_pkController = new KController();
	m_pkController->Init(m_pkMapGrid, m_pkUserGrid,
		m_pkDataProvider, m_pkUI, m_pkOperationManager);

	PROCESS_ERROR(m_pkMapGrid);
	PROCESS_ERROR(m_pkUserGrid);
	PROCESS_ERROR(m_pkDataProvider);
	PROCESS_ERROR(m_pkUI);
	PROCESS_ERROR(m_pkOperationManager);
	PROCESS_ERROR(m_pkController);
	bEC = true;
Exit0:
	return bEC;
}

bool KSudokuGame::StartGame(void)
{
	m_pkController->StartGame();
	return true;
}
